package com.crm.service.impl;

import java.util.List;
import java.util.Map;

import com.crm.dao.SysUserDao;
import com.crm.dao.impl.SysUserDaoImpl;
import com.crm.pojo.SysUser;
import com.crm.service.SysUserService;

public class SysUserServiceImpl implements SysUserService {
	SysUserDao userDao = new SysUserDaoImpl();
	@Override
	public boolean loginUser(String userName, String pwd) {
		boolean flag = false;
		List<Map> user = userDao.queryUser(userName,pwd);
		if(user.size()==1) {
			flag = true;
		}
		return flag;
	}
	@Override
	public SysUser queryUser(String userName) {
		List<Map> users = userDao.queryUser(userName);
		SysUser user = new SysUser();
		for(Map u:users) {
			user.setUserId(Integer.parseInt(u.get("user_id").toString()));
			user.setUserCode((String)u.get("user_code"));
			user.setUserName((String)u.get("user_name"));
			user.setPassword((String)u.get("user_password"));
			user.setState((String)u.get("user_stare"));
		}
		return user;
	}

}
